home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #9 / Amiga Plus CD - 2004 - No. 09.iso / amigaplus / tools / dev_libs / feelin040718 / sources / bar / object.c next >
C/C++ Source or Header  |  2004-08-03  |  4KB  |  183 lines

  1. #include "Private.h"
  2.  
  3. /*** Methods ***************************************************************/
  4.  
  5. ///Bar_New
  6. F_METHODM(APTR,Bar_New,TagItem)
  7. {
  8.    struct LocalObjectData *LOD = F_LOD(Class,Obj);
  9.    struct TagItem         *Tags = Msg,
  10.                            item;
  11.  
  12.    LOD -> p_PreParse = "FP_Bar_PreParse";
  13.    LOD -> AreaData   = (FAreaData *) F_Get(Obj,FA_AreaData);
  14.  
  15.    if (F_SUPERDO())
  16.    {
  17.       while  (F_DynamicNTI(&Tags,&item,Class))
  18.       switch (item.ti_Tag)
  19.       {
  20.          case FA_Bar_Title:      LOD -> Title    = (STRPTR)(item.ti_Data); break;
  21.          case FA_Bar_PreParse:   LOD -> PreParse = (STRPTR)(item.ti_Data); break;
  22.       }
  23.       return Obj;
  24.    }
  25.    return NULL;
  26. }
  27. //+
  28. ///Bar_Get
  29. F_METHOD(void,Bar_Get)
  30. {
  31.    struct LocalObjectData *LOD = F_LOD(Class,Obj);
  32.    struct TagItem         *Tags = Msg,
  33.                            item;
  34.    BOOL up=FALSE;
  35.  
  36.    while  (F_DynamicNTI(&Tags,&item,Class))
  37.    switch (item.ti_Tag)
  38.    {
  39.       case FA_Bar_Title:      F_STORE(LOD -> Title);    break;
  40.       case FA_Bar_PreParse:   F_STORE(LOD -> PreParse); break;
  41.  
  42.       default: up = TRUE;
  43.    }
  44.  
  45.    if (up) F_SUPERDO();
  46. }
  47. //+
  48. ///Bar_Setup
  49. F_METHOD(ULONG,Bar_Setup)
  50. {
  51.    struct LocalObjectData *LOD = F_LOD(Class,Obj);
  52.  
  53.    if (F_SUPERDO())
  54.    {
  55.       if (F_Get(_parent,FA_Horizontal)) LOD -> Flags |= FF_Bar_Vertical;
  56.       else                              LOD -> Flags &= ~FF_Bar_Vertical;
  57.  
  58.       if (LOD -> Title)
  59.       {
  60.          LOD -> PreParse = (STRPTR) F_Do(_app,FM_Application_Resolve,LOD -> p_PreParse,"<pens style=\"glow\">");
  61.  
  62.          LOD -> TD = F_NewObj("TextDisplay",
  63.                                FA_TextDisplay_Contents,  LOD -> Title,
  64.                                FA_TextDisplay_PreParse,  LOD -> PreParse,
  65.                                FA_TextDisplay_Font,      _font,
  66.                                TAG_DONE);
  67.  
  68.          if (LOD -> TD)
  69.          {
  70.             return F_Do(LOD -> TD,FM_TextDisplay_Setup,_render);
  71.          }
  72.       }
  73.       return TRUE;
  74.    }
  75.    return FALSE;
  76. }
  77. //+
  78. ///Bar_Cleanup
  79. F_METHOD(ULONG,Bar_Cleanup)
  80. {
  81.    struct LocalObjectData *LOD = F_LOD(Class,Obj);
  82.  
  83.    if (LOD -> TD)
  84.    {
  85.       F_Do(LOD -> TD,FM_TextDisplay_Cleanup);
  86.       F_DisposeObj(LOD -> TD); LOD -> TD = NULL;
  87.    }
  88.    return F_SUPERDO();
  89. }
  90. //+
  91. ///Bar_AskMinMax
  92. F_METHOD(ULONG,Bar_AskMinMax)
  93. {
  94.    struct LocalObjectData *LOD = F_LOD(Class,Obj);
  95.  
  96.    if (LOD -> Title)
  97.    {
  98.       if ((LOD -> Flags & FF_Bar_Vertical) == FALSE)
  99.       {
  100.          _minh += F_Get(LOD -> TD,FA_TextDisplay_Height);
  101.       }
  102.    }
  103.    else
  104.    {
  105.       if (LOD -> Flags & FF_Bar_Vertical)
  106.       {
  107.          _minw += 2;
  108.          _maxw  = _minw;
  109.       }
  110.       else
  111.       {
  112.          _minh += 2;
  113.          _maxh  = _minh;
  114.       }
  115.    }
  116.    return F_SUPERDO();
  117. }
  118. //+
  119. ///Bar_Draw
  120. F_METHODM(void,Bar_Draw,FS_Draw)
  121. {
  122.    struct LocalObjectData *LOD = F_LOD(Class,Obj);
  123.    struct RastPort *rp;
  124.    ULONG  dark,shine;
  125.    UWORD  x1,y1,x2,y2,w,h, bw;
  126.    
  127.    rp = _rp;
  128.    x1 = _x; w = _w; x2 = x1 + w - 1; dark  = _pens[FV_Pen_Dark];
  129.    y1 = _y; h = _h; y2 = y1 + h - 1; shine = _pens[FV_Pen_Shine];
  130.  
  131.    F_SUPERDO();
  132.  
  133.    if (LOD -> Flags & FF_Bar_Vertical)
  134.    {
  135.       if (w > 2) x1 = w / 2 + x1 - 1;
  136.  
  137.       _APen(dark);  _Move(x1,y1);   _Draw(x1,y2);
  138.       _APen(shine); _Move(x1+1,y1); _Draw(x1+1,y2);
  139.    }
  140.    else
  141.    {
  142.       if (LOD -> Title)
  143.       {
  144.          FRect rect;
  145.          UWORD td_w;
  146.  
  147.          rect.x1 = x1+10+1; rect.y1 = y1;
  148.          rect.x2 = x2-10-1; rect.y2 = y2;
  149.  
  150.          F_Do(LOD -> TD,FM_Set,
  151.                         FA_TextDisplay_Width,   rect.x2 - rect.x1 + 1,
  152.                         FA_TextDisplay_Height,  rect.y2 - rect.y1 + 1,
  153.                         TAG_DONE);
  154.  
  155.          td_w = F_Get(LOD -> TD,FA_TextDisplay_Width);
  156.  
  157.          if (td_w == 0)
  158.          {
  159.             goto __done;
  160.          }
  161.  
  162.          bw = (w - 10 - td_w) / 2;
  163.          y1 = (h / 2) + y1;
  164.  
  165.          _APen(shine); _Move(x1,y1);   _Draw(x1+bw-1,y1);   _Move(x2-bw+1,y1);   _Draw(x2,y1);
  166.          _APen(dark);  _Move(x1,y1-1); _Draw(x1+bw-1,y1-1); _Move(x2-bw+1,y1-1); _Draw(x2,y1-1);
  167.  
  168.          rect.x1 = x1+bw+5; rect.x2 = x2-bw-5;
  169.  
  170.          F_Do(LOD -> TD,FM_TextDisplay_Draw,&rect);
  171.       }
  172.       else
  173.       {
  174. __done:
  175.          if (h > 2) y1 = h / 2 + y1 - 1;
  176.  
  177.          _APen(dark);  _Move(x1,y1);   _Draw(x2,y1);
  178.          _APen(shine); _Move(x1,y1+1); _Draw(x2,y1+1);
  179.       }
  180.    }
  181. }
  182. //+
  183.